<?php  ?>
<h2><?php echo $lang_Start_Surveys; ?><hr/></h2>
<form id="frmCancelLeave" name="frmCancelLeave" method="post" action="">
<table border="0" cellpadding="0" cellspacing="0">
  <thead>
  	<tr>
		<th class="tableTopLeft"></th>
    	<th class="tableTopMiddle" width="500"></th>
    	<th class="tableTopMiddle" ></th>            	
		<th class="tableTopRight"></th>
	</tr>
	<tr>
		<th class="tableMiddleLeft"></th>
    	<th class="tableMiddleMiddle">Survey Name</th>
    	<th class="tableMiddleMiddle" >Time left</th>            	
		<th class="tableMiddleRight"></th>
	</tr>
  </thead>
  <tbody>
<?php
	$j = 0;
	$count =0;
	if (is_array($records) && count($records)>0) {		
		foreach ($records as $record) {
			//$surveyOwner = 
			if(!($j%2)) {
				$cssClass = 'odd';
			 } else {
			 	$cssClass = 'even';
			 }
			$today = mktime(0, 0, 0, date('m'), date('d'), date('Y')); 
			$dayleft = (strtotime($record->getSurveyToDate())-$today) / 86400;
			 $answers = Answers::getAnswersBySurveyUser($record->getId(),$_SESSION['empID']);
    		if(count($answers)==0 && (in_array($_SESSION['empID'],explode(",",$record->getSurveyUsers()))||in_array($_SESSION['empID'],explode(",",$record->getSurveySentEmail())))){ $count++; $j++;?>
			  <tr>
			  	<td class="tableMiddleLeft"></td>
			    <td class="<?php echo $cssClass; ?>">
			    	<a href="CentralController.php?surveycode=Surveys&action=StartSurvey&id=<?php echo $record->getId(); ?>" target="rightMenu"><?php echo $record->getSurveyName(); ?></a>
			    </td>
			    <td class="<?php echo $cssClass; ?>"><?php echo $dayleft." day(s)" ?></td>	    
				<td class="tableMiddleRight"></td>
			  </tr>
			
			<?php
    		}
		}
		if($count==0){?> 
		<tr>
		  	<td class="tableMiddleLeft"></td>
		    <td class="">No survey available now</td>
		    <td class=""></td>    
			<td class="tableMiddleRight"></td>
  		</tr>
		<?php } 
	}else{ ?>
		<tr>
		  	<td class="tableMiddleLeft"></td>
		    <td class="">No survey avaible now</td>    
		    <td class=""></td>
			<td class="tableMiddleRight"></td>
  		</tr>
		
	<?php }
?>
  </tbody>
  <tfoot>
  	<tr>
		<td class="tableBottomLeft"></td>
		<td class="tableBottomMiddle"></td>
		<td class="tableBottomMiddle"></td>				
		<td class="tableBottomRight"></td>
	</tr>
  </tfoot>
</table>

